from socket import *
from threading import Thread

def fun(sock,destAddr):
    while True:
        recvData = sock.recv(1024)
        if len(recvData) > 0 :
            print("%s>>%s"%(str(destAddr),recvData))
        else:
            print("%s客户端已经关闭" % str(destAddr))
            break
    sock.close()

serSocket = socket(AF_INET,SOCK_STREAM)
localAddr = ("",7788)
serSocket.bind(localAddr)
serSocket.listen(5)

while True:
    newSocket,destAddr = serSocket.accept()
    thread1 = Thread(target=fun,args=(newSocket,destAddr))
    thread1.start()
serSocket.close()